﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Factur_IT.Admin
{
    public partial class addCompany : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            bool loggedIn = FacturIT.Service.FacturITManager.Instance.IsLoggedID();

            if (loggedIn != true)
                Response.Redirect("~/Account/login.aspx");
        }

        protected void bntSave_Click(object sender, EventArgs e)
        {
            string name = txtNaam.Text;
            string address = txtAdres.Text;
            string pc = txtPostcode.Text;
            string city = txtStad.Text;
            string country = txtLand.Text;
            string phone = txtTel.Text;
            int owner = Convert.ToInt32(Session["UserID"]);

            FacturIT.Service.FacturITManager.Instance.AddCompany(name, address, pc, city, country, phone, owner);
            int companyid = FacturIT.Service.FacturITManager.Instance.ReadCompanyByName(name).CompanyID;
            FacturIT.Service.FacturITManager.Instance.AddUserToCompany(owner, companyid);

        }

    }
}